//供应商管理-供应商列表
App.util.ns('Admin.Supplier.Supplier');
App.pages.add((function(){
    var NS = Admin.Supplier.Supplier;
    var page = new App.Page({
        name: 'supplier/supplier/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-support"></i>',
            content: '供应商管理'
        }, {
            content: '供应商列表'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/supplier/supplier',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                showId: false,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'}
            ],
            menu: [
                {parent: 'add', permission: 'op:admin.supplier.supplier.create'},
                {parent: 'view', permission: 'op:admin.supplier.supplier.detail'},
                {parent: 'edit', permission: 'op:admin.supplier.supplier.update'},
                {type: 'inline', permission: 'op:admin.supplier.supplier', name: '重置密码', operation: function(dataTable, supplier){
                    var win = dataTable.wins.get('resetPassword');
                    win.form.change({password: '', re_password: '', id: supplier.id});
                    win.setTitle('重置密码 - '+supplier.name+'（'+supplier.name+'）');
                    win.show();
                }},
                {type: 'inline', permission: 'op:admin.supplier.supplier.open', name: '开启', operation: {type: 'change', url: 'open'}, conditions: [['status', '0']]},
                {type: 'inline', permission: 'op:admin.supplier.supplier.close', name: '禁用', operation: {type: 'change', url: 'close'}, conditions: [['status', '1']]},
                {parent: 'drop', permission: 'op:admin.supplier.supplier.delete'},
                {parent: 'multiDrop', permission: 'op:admin.supplier.supplier.multiDelete'},
                {parent: 'oplog', permission: 'op:admin.supplier.supplier.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form),
                    add: 'all',
                    edit: 'except:username,password,re_password',
                    view: 'except:username,password,re_password'
                }
            },
            after: function(dataTable){
                dataTable.wins.add(new NS.ResetPassword(dataTable), 'resetPassword');
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());